package com.controller.backend;

import com.biz.HotelHomeBiz;
import com.core.Result;
import com.core.ResultGenerator;
import com.entity.model.HotelHome;
import com.github.pagehelper.PageInfo;
import com.util.webpage.PageData;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import tk.mybatis.mapper.entity.Condition;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Created by jc on 2019/11/16.
 */
@Controller
@RequestMapping("/backend/security/hotelHome")
public class HotelHomeController extends BaseController<HotelHome> {
    @Autowired
    private HotelHomeBiz hotelHomeBiz;

    //房间详情页面
    @RequestMapping(value = "detail")
    public String detail() throws Exception {
        return "/backend/security/hotel/hotelHomeForm";
    }

    //获取门店信息以及上下架状态
    @RequestMapping(value = "addHome")
    @ResponseBody
    public Result addHome(HotelHome hotelHome) {

        hotelHomeBiz.save(hotelHome);


        return ResultGenerator.genSuccessResult();
    }


    //重新计算房间总数量
    public Integer totalNum(Integer hotelId) {
        Condition condition = new Condition(HotelHome.class);
        condition.createCriteria().andEqualTo("status", 0).andEqualTo("hotelId", hotelId);
        List<HotelHome> hotelHomeList = hotelHomeBiz.findByCondition(condition);

        return 0;
    }
}
